<?php

namespace app\api\controller;

use app\common\controller\Api;
use addons\epay\library\Service as EpayService;
use EasyWeChat\Foundation\Application as WXPAY_APP;
use EasyWeChat\Payment\Order as WXPAY_ORDER;
use addons\third\model\Third;
use think\Config;
use think\Db;
use app\admin\model\Shangcheng;

/**
 * 商城接口
 */
class Shop extends Api
{
    // protected $noNeedLogin = ['mp3_detail','index','mp3_list'];
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function _initialize()
    {
        parent::_initialize();
        $this->user_id = $this->auth->id;
        // $this->user_id = 2;
    }  

     /**
     * 商品列表
     * @ApiSummary  ()
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/shop/list)
     * @ApiReturn({
       
     })
     */
    public function list(){
      $sc_type = Db::name('sc_type')->field('name,id')->order('weigh desc')->select();
      foreach ($sc_type as $key => $value) {
        $return[$key]['type'] = $value['name'];
        $return[$key]['list'] = Db::name('shangcheng')->where('sc_type_id',$value['id'])->field('name,id,image')->select();
      }
        $this->success('商品列表',$return);
    }
    /**
     * 商城商品详情
     * @param int $id 
     */
    public function shop_detail(){
      $Shangcheng = new Shangcheng();
      $id = input('id');
      $detail = $Shangcheng->get($id);

      $this->success('商城商品详情',$detail);
    }

  

}
